// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_img.p_video;

import android.content.*;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Handler;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;

// Referenced classes of package com.nnee.p_img.p_video:
//            w, y, z, aa

public class cls_ab
    implements android.media.MediaPlayer.OnCompletionListener, android.media.MediaPlayer.OnErrorListener
{

    public cls_ab(View view, Context context, Uri uri)
    {
        n = -1;
        o = false;
        b = new Handler();
        c = new cls_w(this);
        m = context.getContentResolver();
        j = (VideoView)view.findViewById(0x7f0d0033);
        k = view.findViewById(0x7f0d0034);
        l = uri;
        String s = l.getScheme();
        Intent intent;
        Integer integer;
        if("http".equalsIgnoreCase(s) || "rtsp".equalsIgnoreCase(s))
            b.postDelayed(c, 250L);
        else
            k.setVisibility(8);
        j.setOnErrorListener(this);
        j.setOnCompletionListener(this);
        j.setVideoURI(l);
        p = new MediaController(context);
        j.setMediaController(p);
        j.requestFocus();
        intent = new Intent("com.android.music.musicservicecommand");
        intent.putExtra("command", "pause");
        context.sendBroadcast(intent);
        integer = d();
        if(integer != null)
        {
            android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(context);
            builder.setTitle("resume_playing_title");
            Object aobj[] = new Object[1];
            aobj[0] = integer;
            builder.setMessage(String.format("resume_playing_message", aobj));
            builder.setOnCancelListener(new cls_y(this));
            builder.setPositiveButton("resume_playing_resume", new cls_z(this, integer));
            builder.setNegativeButton("resume_playing_restart", new cls_aa(this));
            builder.show();
        } else
        {
            j.start();
        }
    }

    private static int a(Cursor cursor, int i1)
    {
        int j1 = 0;
        int k1 = cursor.getInt(i1);
        j1 = k1;
        return j1;
        

    }

    static VideoView a(cls_ab ab1)
    {
        return ab1.j;
    }

    private void a(int i1)
    {
        if(a(l))
        {
            ContentValues contentvalues = new ContentValues();
            contentvalues.put("bookmark", Integer.toString(i1));
            try
            {
                m.update(l, contentvalues, null, null);
            }
            catch(SecurityException securityexception) { }
            catch(SQLiteException sqliteexception) { }
            catch(UnsupportedOperationException unsupportedoperationexception) { }
        }
    }

    private static boolean a(Uri uri)
    {
        String s = uri.getScheme();
        String s1 = uri.getAuthority();
        boolean flag;
        if("content".equalsIgnoreCase(s) && "media".equalsIgnoreCase(s1))
            flag = true;
        else
            flag = false;
        return flag;
    }

    static View b(cls_ab ab1)
    {
        return ab1.k;
    }

    private Integer d()
    {
    	 Integer integer = null;
        if(a(l)) {
        	 String as[];
             as = new String[2];
             as[0] = "duration";
             as[1] = "bookmark";
             Cursor cursor = m.query(l, as, null, null, null);
             if(cursor == null)
            	 return integer;
             int i1;
             int j1;
             if(!cursor.moveToFirst())
            	 return integer;
             i1 = a(cursor, 0);
             j1 = a(cursor, 1);
             if(j1 >= 0x1d4c0 && i1 >= 0x493e0 && j1 <= i1 - 60000)
            	 return integer;
             cursor.close();
              
             Integer integer1 = Integer.valueOf(j1);
             integer = integer1;
             cursor.close();
              
        }
        return integer;
 
    }

    public void a()
    {
    }

    public void b()
    {
        b.removeCallbacksAndMessages(null);
        a(j.getCurrentPosition());
        n = j.getCurrentPosition();
        o = j.isPlaying();
        j.stopPlayback();
    }

    public void c()
    {
        if(n >= 0)
        {
            j.setVideoURI(l);
            j.seekTo(n);
            n = -1;
            if(o)
                p.show(0);
        }
    }

    public void onCompletion(MediaPlayer mediaplayer)
    {
        a();
    }

    public boolean onError(MediaPlayer mediaplayer, int i1, int j1)
    {
        b.removeCallbacksAndMessages(null);
        k.setVisibility(8);
        return false;
    }

    private static final String a = "MovieViewControl";
    private static final int d = 60000;
    private static final int e = 0x1d4c0;
    private static final int f = 0x493e0;
    private static final String g = "com.android.music.musicservicecommand";
    private static final String h = "command";
    private static final String i = "pause";
    Handler b;
    Runnable c;
    private final VideoView j;
    private final View k;
    private final Uri l;
    private final ContentResolver m;
    private int n;
    private boolean o;
    private MediaController p;
}
